home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / parapass.zip / PARAPASS.8 < prev    next >
Text File  |  1988-05-31  |  18KB  |  387 lines

  1. ; PROGRAM : parapass
  2. ;
  3. ; VERSION : 0.0 (BETA TEST)  10/20/87
  4. ;
  5. ; INVOCATION : parapass <program name> </q>
  6. ;              the /q option is quiet option, it won't prompt for
  7. ;              parameters but will wait to read them
  8. ;
  9. ; AUTHOR : Rusty Baldwin
  10. ;          4783 W. 133rd St. #12
  11. ;          Hawthorne, CA  90250
  12. ;
  13. ; LANGUAGE : This program was developed with the A86 assembly language
  14. ;            if you want to assemble using MASM your on your own.
  15. ;            To assemble using A86 type : A86 PARAPASS.ASM
  16. ;
  17. ;            A86 can be obtained from:    Eric Isaacson
  18. ;                                         416 E. University
  19. ;                                         Bloomington, IN  47401
  20. ;                                         (812)339-1811
  21. ;
  22. ;
  23. ; DESCRIPTION : This program allows the interactive specification of
  24. ;               command line parameters. Microsoft EDLIN editor for
  25. ;               instance requires that the file to be edited be specified
  26. ;               on the command line (example: edlin myfile.doc). In a
  27. ;               operating environment such as DESQview this may not be
  28. ;               convenient however since parameters which are passed in
  29. ;               environments such as DESQview are static (i.e. you must
  30. ;               be content to edit myfile.doc constantly). This program
  31. ;               was developed to get around that problem. When you run
  32. ;               this program it will prompt you for the file to execute
  33. ;               (which must have a fully qualified path name) and the
  34. ;               parameters to pass to that program. It then runs the
  35. ;               program and 'fools' the program into thinking the para-
  36. ;               meters were passed on the command line.
  37. ;
  38. ;
  39. ; Miscellaneous Equates
  40. ;
  41. space          equ       20h            ; space
  42. cr             equ       0dh            ; carriage return
  43.  
  44. main:          call      init           ; get switches etc. on command line
  45.                test      b[status],80h  ; is quiet bit set?
  46.                jnz       >l1            ; yes
  47.                mov       dx,begin_msg   ; no, output program header
  48.                mov       ah,9h
  49.                int       21h
  50. l1:            mov       bx,[2ch]       ; specify environment block address
  51.                mov       [par_blk],bx   ; pass the environment we got.
  52.                mov       [p1],ds        ; THIS IS KLUDGEY SO I WANT TO
  53.                mov       [p2],ds        ; DO THIS BETTER LATER
  54.                mov       [p3],ds
  55. again:         mov       ch,0           ; clear ch
  56.                mov       cl,[80h]       ; get length of command tail
  57.                mov       al,[prg_add]   ; see if we have a program name
  58.                cmp       al,0
  59.                jne       >l1            ; yes we do
  60.  
  61. getname:       mov       dx,name_msg    ; nope, get program name
  62.                mov       ah,9h          ; this will send prompt even
  63.                int       21h            ; if quiet bit is set.
  64.                mov       b[80h],7fh     ; allow 128 bytes length
  65.                mov       dx,80h         ; get program name
  66.                mov       ah,0ah
  67.                int       21h
  68.                mov       ah,[81h]       ; get length of read
  69.                inc       ah             ; increase it by one
  70.                mov       [80h],ah       ; with this section we are
  71.                mov       b[81h],space   ; simulating, getting the program
  72.                                         ; name on the command line
  73.                call      init           ; call init again
  74.                jmp       again          ; try it again
  75.  
  76. l1:            call      valid          ; check validity of filename
  77.                cmp       al,0eh         ; invalid name? (0eh invalid
  78.                jne       >l2            ; file name error code)
  79.                jmp       alt            ; yes, display error message
  80.                                         ; use alternate entry point
  81. l2:            mov       si,[prg_add]   ; source pointer to name of program to run
  82.                and       si,0ffh        ; make sure msb is zero
  83.                mov       di,prg_nam     ; destination pointer
  84. l3:            mov       al,[si]        ; get a byte
  85.                mov       [di],al        ; put it in destination
  86.                inc       si             ; take care of pointers and such
  87.                inc       di
  88.                loop      l3             ; go get some more
  89.                mov       b[si],' '      ; put ' : $' at end of command tail for later use
  90.                inc       si             ; so we can output to user
  91.                mov       b[si],':'
  92.                inc       si
  93.                mov       b[si],'$'
  94.                test      b[status],80h  ; is quiet bit set?
  95.                jnz       >l1            ; yes
  96.                mov       dx,crlf        ; output crlf
  97.                mov       ah,9h
  98.                int       21h
  99.                mov       dx,prompt      ; prompt for parameters
  100.                mov       ah,9h          ; output it
  101.                int       21h
  102.                mov       dl,[prg_add]   ; output program name
  103.                mov       dh,0
  104.                int       21h
  105.                mov       dx,crlf        ; output crlf
  106.                mov       ah,9h
  107.                int       21h
  108. l1:            mov       dx,cmd_line-1  ; get cmd_line
  109.                mov       ah,0ah
  110.                int       21h
  111.                mov       dx,crlf        ; output crlf
  112.                mov       ah,9h
  113.                int       21h
  114.                mov       ah,29h         ; put cmd_line in FCB #1
  115.                mov       al,01          ; in case program looks there
  116.                mov       si,offset cmd_line+1
  117.                mov       di,ds
  118.                mov       es,di
  119.                mov       di,offset fcb1
  120.                int       21h
  121.                mov       [stk_seg],ss   ; save stack
  122.                mov       [stk_off],sp
  123.                mov       ah,25h         ; intercept any <CNTRL> C
  124.                mov       al,23h         ; so we can ingore it
  125.                mov       dx,int_ret
  126.                int       21h            ; ds should already be correct
  127.                mov       ah,4ah         ; release memory for EXEC'd program
  128.                mov       bx,eop-main    ; eop-main = program length in bytes
  129.                shr       bx,4           ; divide bx by 16 for paragraph length
  130.                add       bx,11h         ; add enough to take care of PSP
  131.                int       21h            ; release memory
  132.                mov       dx,prg_nam     ; set up to EXEC program
  133.                mov       bx,par_blk
  134.                mov       al,0
  135.                mov       ah,4bh
  136.                int       21h            ; EXEC program
  137.                mov       ss,[stk_seg]   ; restore stack
  138.                mov       sp,[stk_off]
  139.                jc        alt            ; if error print message
  140.                jmp       good_exit      ; if no error were done
  141.  
  142. int_ret:       iret                     ; dummy interrupt handler
  143.  
  144. alt:           mov       bl,al          ; convert error number to ASCII
  145.                cmp       bl,0ah
  146.                jg        >l1
  147.                add       bl,30h         ; convert to ASCII 1-9
  148.                mov       [error],bl
  149.                jmp       >l2
  150. l1:            add       bl,37h         ; convert to ASCII A-Z
  151.                mov       [error],bl     ; put error number in head_msg
  152. l2:            mov       dx,head_msg    ; output header
  153.                push      ax             ; save ax
  154.                mov       ah,9h
  155.                int       21h
  156.                pop       ax             ; restore it
  157.                cmp       al,1h          ; oh no an error,find out which one
  158.                je        err1           ; err1=function invalid
  159.                cmp       al,2h
  160.                je        err2           ; err2=file not found,path invalid
  161.                cmp       al,5h
  162.                je        err5           ; err5=access denied
  163.                cmp       al,8h
  164.                je        err